<!DOCTYPE HTML>

<html>
<head>
<title>ActionScript vs JavaScript</title>

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
<!--
// Embed the SWF file (will replace contents of 'alternativeContent' with swf)
var flashvars = {};
var params = {};
var attributes = {};
attributes.id = "flashObj";
swfobject.embedSWF("visualizer.swf", "alternateContent", "550", "400", "10.0.0", false, flashvars, params, attributes);

const PLAYLIST1 = 0;
const PLAYLIST2 = 1;
const PLAYLIST3 = 2;
const PLAYLIST4 = 3;


// FLASH TO JAVASCRIPT
function loadComplete(playlist)
{
	var flashObj = document.getElementById('flashObj');
	flashObj.playTrack(playlist);
}

function loadProgress(playlist,percentLoaded)
{
	document.getElementById("loadProgress").innerHTML = "Loading PLAYLIST"+(playlist+1)+", Percent Loaded: "+percentLoaded+"%";
}

function playbackProgress(playlist,percentPlayed)
{
	document.getElementById("playbackProgress").innerHTML = "Playing PLAYLIST"+(playlist+1)+", Percent Played: "+percentPlayed+"%";
}

function playbackComplete(playlist)
{
	alert("PLAYLIST"+(playlist+1)+" has finished");
}

// JAVASCRIPT TO FLASH
function loadAndPlay(playlist)
{
	var flashObj = document.getElementById('flashObj');
    flashObj.loadTrack("http://redwood.colorado.edu/henkeb/testTrack.mp3",playlist);
    flashObj.adjustVolume(0,100,0,0);
}

function pause(playlist)
{
	var flashObj = document.getElementById('flashObj');
	flashObj.pauseTrack(playlist);
}

function resume(playlist)
{
	var flashObj = document.getElementById('flashObj');
	flashObj.playTrack(playlist,true);
}

function fastFoward(playlist)
{
	var flashObj = document.getElementById('flashObj');
	flashObj.playTrack(playlist,false,95);
}



//-->
</script>

</head>
<body>

<div id="flashContentDiv"> <div id="alternateContent"> Please update your flash player to view this content. </div> </div>

<div id="loadProgress"> Load Progress </div>
<div id="playbackProgress"> Playback Progress </div>
<a href="#" onClick="loadAndPlay(1)"> Load and Play </a> <br />
<a href="#" onClick="pause(1)"> Pause </a> <br />
<a href="#" onClick="resume(1)"> Resume </a> <br />
<a href="#" onClick="fastFoward(1)"> Fast Foward </a> <br />

</body>
</html>
